<!-- 基础信息 -->

<template>
  <div>
    <MajorTitle title="基础信息" />

    <FormInput label="档案名称" bind="name" required />

    <EasyRow col3>
      <MyEvent />
      <FormSelect label="事件等级" bind="eventLevelCode, eventLevelName" :dict="DICT.LEVEL" initFirst />
      <FormSelect label="事件类型" bind="eventTypeId, eventTypeName" :dict="CORE.DICT.preplan_type" initFirst />
    </EasyRow>

    <EasyRow col3>
      <FormTime label="产生时间" bind="generateTime" history required @change="changeDuring" />
      <FormTime label="处置时间" bind="handleTime" history required />
      <FormTime label="完成时间" bind="finishTime" history required @change="changeDuring" />
    </EasyRow>

    <EasyRow col3>
      <FormTree
        :label="`所在${CORE.MAP.REGION}`"
        bind="areaId, areaName"
        :dict="CORE.REGION.DICT"
        allName
        third2
        required
      />
      <FormInput label="全程用时" bind="duringText" disabled />
    </EasyRow>

    <FormTextarea label="事件详情" bind="detail" :rows="[2, 5]" />

    <FormFile label="关联文件" bind="fileInfoDtos" folder="emergency" />
  </div>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'MyBase',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixWeb()],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听时长
     */
    'one.handleDuration'(during) {
      this.one.duringText = CORE.numDuringTwo((during / 1000) | 0)
    },
  },

  /**
   * 本地方法 (轻量重要在前)
   */
  methods: {
    /**
     * 更新时长
     */
    changeDuring() {
      const { one } = this
      one.handleDuration = one.finishTime - one.generateTime
    },
  },
}
</script>
